var prefix = "/api/system/role";
$(function () {
    load();
    $(".chosen-select").chosen({
        allow_single_deselect: true  //是否允许取消选择
        ,max_selected_options:10  //设置最大选项个数
        ,disable_search:false   //设置下拉多选框可见
    });

    $("#select-box .chosen-select").bind("chosen:maxselected",function (e) {
        alert("最多只能选择10个！");
        return;
    });

});

function load() {
    var url = window.location.href
    var id = url.charAt(url.length - 1)
    $('#exampleTable').bootstrapTable(
        {
            method: 'get',
            url: prefix + "/"+id+"/users",
            iconSize: 'outline',
            toolbar: '#exampleToolbar',
            striped: true,
            dataType: "json",
            pagination: true,
            clickToSelect: true,
            pageSize: 10,
            pageNumber: 1,
            showColumns: false,
            sidePagination: "client",
            contentType: "application/x-www-form-urlencoded",

            onClickRow: function (row, $element) {
                $element.addClass('info').siblings().removeClass('info').end();
            },
            columns: [
                {
                    title: '序号',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {
                    field: 'workNo',
                    title: '工号'
                },
                {
                    field: 'userName',
                    title: '姓名'
                },
                {
                    field: 'deptName',
                    title: '部门'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return [
                            '<a class="btn btn-sm btn-info" href="#" title="移除" onclick="deleteUser(' + row.id + ')">',
                            '<i class="glyphicon glyphicon-edit"></i>',
                            '</a>&nbsp;&nbsp;',
                        ].join('');
                    }
                }]
        })
}


//角色组删除单个用户
function deleteUser(userId){

}